from django.db import models
from django.contrib.auth.models import User


class UserInformation(models.Model):
    user_email = models.EmailField(
        null=True, max_length=32, verbose_name='用户邮箱')
    user_friends_id = models.IntegerField(null=True, verbose_name='用户好友id')
    user_sex = models.BooleanField(null=True, verbose_name='用户性别')
    user_birthday = models.DateField(null=True, verbose_name='用户生日')
    user_age = models.IntegerField(null=True, verbose_name='用户年龄')
    user_area = models.CharField(null=True, max_length=32, verbose_name='用户地区')
    user_qq = models.CharField(null=True, max_length=16, verbose_name='用户qq')
    user_telephone = models.CharField(
        null=True, max_length=16, verbose_name='用户电话')
    user_school = models.CharField(
        null=True, max_length=16, verbose_name='用户学校')
    user_signature = models.TextField(null=True, verbose_name='用户个性签名')
    user_id = models.OneToOneField(User, on_delete=models.CASCADE)


class UserCreatedBook(models.Model):
    created_book_id = models.IntegerField(null=True, verbose_name='已创建单词本id')
    share_book = models.BooleanField(default=True, verbose_name='是否分享')
    user_id = models.ForeignKey(User, on_delete=models.CASCADE)


class UserBooks(models.Model):
    # wordbook_id = models.IntegerField(primary_key=True)
    # 单词书名称
    title = models.CharField(max_length=32)
    # 创建添加时间
    pub_date = models.DateField()
    # 是否公开
    is_public = models.BooleanField(default=True)
    # 密码
    password = models.CharField(max_length=64, default='')
    # 是否需要密码
    need_pwd = models.BooleanField(default=False)
    # 所属用户
    master = models.ManyToManyField(User)


class UserWordMemorize(models.Model):
    id = models.IntegerField(
        primary_key=True, max_length=30, verbose_name='单词ID')
    word_id = models.IntegerField(max_length=30, verbose_name='单词ID')


class UserWordNotes(models.Model):

    word_id = models.IntegerField(max_length=30, verbose_name='单词ID')
    word_notes = models.TextField(null=True, verbose_name='单词笔记')
    user_id = models.ForeignKey(User, on_delete=models.CASCADE)

    def __str__(self):
        return self.word_id
